package nextoffer.mihayou;

import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeMap;

public class First {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

            int n = in.nextInt();
            int a[] = new int[n];
            int b[] = new int[n];
        int sum1 =  0;
        int sum2 =  0;
            for(int i =0 ; i < n;i++){
                a[i] = in.nextInt();
                sum1+= a[i];
            }
        int max= 0;
        for(int i =0 ; i < n;i++){
            b[i] = in.nextInt();
            sum2+=b[i];
        }

        for(int i = 0; i < n;i++){
            max = Math.max(max, sum2 ^ (sum1 - a[i]));
        }
        for(int i = 0; i < n;i++){
            max = Math.max(max, sum1 ^ (sum2 - b[i]));
        }
        System.out.println(max);



    }
}
